const express = require('express')
const app = express();

const mysql = require('mysql')
const db = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "123456",
    database: "users",
})
db.connect()

const router = express.Router();

app.use("/api", router);

router.get('/books',(req,res)=>{
    db.query('select * from books',(err,result,fields)=>{
        if(err) throw err;
        res.send(result)
    })
})

app.use(express.json());
app.use(express.urlencoded())

app.listen(8080, () => {
    console.log("8080 running");
  });